<?php

class Quad_Cfg {
	
	protected static $_cache = array(); 
	
	public static function get($name = 'app', $filename = false) {
		if (!isset(self::$_cache[$name])) {			
			//$ext = pathinfo($filename,PATHINFO_EXTENSION);
			$ext = 'ini';
			switch ($ext) {
				case 'ini':
					$cfg = new Quad_Cfg_Ini();
					break;
					
				default:
					throw new Quad_Exception("Extension `$ext` are not supported.");
			}
			if ($filename) {
				$cfg->load($filename);
				$cfg->enableObjectNotation();
			}
		}
		self::$_cache[$name] = $cfg;
		return self::$_cache[$name];
	}
				
}